package leetCode;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
@SuppressWarnings("all")
public class greedyAlgorithm {
    public static void main(String[] args) {
          class mooncake{
            double store;
            double totPrice;
            double unitPrice;

            public double getStore() {
                return store;
            }

            public  void setStore(double store) {
                this.store = store;
            }

            public double getTotPrice() {
                return totPrice;
            }

            public void setTotPrice(double totPrice) {
                this.totPrice = totPrice;
            }

            public double getUnitPrice() {
                return unitPrice;
            }

            public  void setUnitPrice(double unitPrice) {
                this.unitPrice = unitPrice;
            }
        }
        int kinds = 0;
        int need = 0;
        Scanner sc = new Scanner(System.in);
        kinds = sc.nextInt();
        need = sc.nextInt();
        mooncake[] mo = new mooncake[kinds];
        int index = 10;
        for(int i =0;i<kinds;i++){
            mo[i] = new mooncake();
            mo[i].setStore(sc.nextDouble());
        }
        for(int i =0;i<kinds;i++){
            mo[i].setTotPrice(sc.nextDouble());
            mo[i].setUnitPrice(mo[i].getTotPrice()/mo[i].getStore());
        }
        Arrays.sort(mo, new Comparator<mooncake>() {
            @Override
            public int compare(mooncake o1, mooncake o2) {
                if(o1.unitPrice < o2.unitPrice){
                    return 1;
                }else{
                    return -1;
                }
            }
        });
        double sumProfit = 0;
        for(int i=0;i<kinds;i++){
            if(mo[i].getStore()>=need){
                sumProfit+=need*mo[i].getUnitPrice();
                break;
            }else{
                sumProfit+=mo[i].getTotPrice();
                need-=mo[i].getStore();
            }
        }
        System.out.println(sumProfit);
    }
}
